<?php 

	$name 				= $this->formText('name',$this->Item['name'],array('class'=>'txtmedium'));
	//$alias 				= $this->formText('alias',$this->Item['alias'],array('class'=>'txtmedium'));
	//$picture 			= $this->formFile('picture',array('style'=>'width: 250px'));
	//$GroupCategory 		= $this->cmsSelect('cat_id',$this->Item['cat_id'],$this->tblGroupCategory,
//										array('style'=>'width:200px','size'=>10));
	$summary 			= $this->formTextarea('summary',str_replace('\\', '', $this->Item['summary']),array('rows'=>'10'));									
	$description_html 	= $this->formTextarea('description_html',str_replace('\\', '', $this->Item['description_html']),array('rows'=>'10'));									
	$keywords_html 		= $this->formTextarea('keywords_html',str_replace('\\', '', $this->Item['keywords_html']),array('rows'=>'10'));									
	//$content			= $this->cmsReplaceString($this->Item['content']);
	//$content			= $this->cmsEditor('content',$content,array('toolbar'=>'Default','language'=>'vi'));
	$options 			= array($this->translate('Inactive'),$this->translate('Active'));
	$status 			= $this->formRadio('status',$this->Item['status'],null,$options, ' ');		
	//$options 			= array($this->translate('No'),$this->translate('Yes'));
	//$special 			= $this->formRadio('special',$this->Item['special'],null,$options, ' ');
	
	//$options 			= array('No','Yes');
	//$featured 			= $this->formRadio('featured',$this->Item['featured'],null,$options, ' ');
	
	//$multiUpload 		= $this->formFile('file_upload',array('style'=>'width: 250px'));
	
	/*...........Picture............*/
//	$imgArr 		= !empty($this->Item['picture'])?array( FILES_URL . '/news/images100x100/'.$this->Item['picture']):'';
//	$image 	= $this->cmsUserAvatar($inputInfo, $imgArr);
//	if(!empty($this->Item['picture'])){
//	  	$urlimage   = FILES_URL . '/news/images100x100/'. $this->Item['picture'];
//	  	$imgimage  = '<span><img src="' . $urlimage . '" width="" height="40"></span>'; 
//	  	$picture  = $imgimage ."<br/>" . $this->formFile('picture',array('style'=>'margin-left:173px'));	
//	}else{
//		$picture  = $this->formFile('picture',array('style'=>'margin-left:5px'));
//	}
// 	$current_stadium = $this->formHidden('current_stadium_picture',$this->Item['picture']);  
	
	$Input = array(
					array('Label'=>$this->translate('Title'),'input'=>$name,'info'=>0),
					//array('Label'=>$this->translate('Alias'),'input'=>$alias,'info'=>0),
					//array('Label'=>$this->translate('Picture'),'input'=>$picture,'info'=>0),
					//array('Label'=>$this->translate('Category'),'input'=>$GroupCategory,'info'=>0),
					array('Label'=>$this->translate('Status'),'input'=>$status,'info'=>0),
					//array('Label'=>$this->translate('Special'),'input'=>$special,'info'=>0),
					//array('Label'=>$this->translate('Featured'),'input'=>$featured,'info'=>0),
					array('Label'=>$this->translate('Summary'),'input'=>$summary,'info'=>0),
					array('Label'=>$this->translate('Description HTML'),'input'=>$description_html,'info'=>0),
					array('Label'=>$this->translate('Keywords HTML'),'input'=>$keywords_html,'info'=>0),
					//array('Label'=>$this->translate('Content'),'input'=>$content,'style'=>'margin-left:174px'),
					//array('Label'=>$this->translate('Select File'),'input'=>$multiUpload,'multiple'=>'true'),
					);
	if(count($this->errors)>0)
	{
		$errors = $this->formErrors($this->errors,array('id'=>'errors'));
	}
?>
<form name="appForm" method="post" action="" enctype="multipart/form-data">

                        <?php echo $this->render('toolbar.php')?>
                        <div class="clr"></div>
                        <?php echo $this->render('sublink.php')?>
                        <?php echo $errors;?>

                        <!-- BEGIN: CONTENT -->
                        <div id="element-box">
                            <div class="t">
                                <div class="t">
                                    <div class="t"></div>
                                </div>
                            </div>
                            <div class="m">
                                <!-- BEGIN: ELEMENT BOX -->
						<div id="adminfieldset">
                            
                            <div class="adminheader">Detail</div>							
							<?php echo $this->partialLoop('rows.php',$Input) ;?>
							<div id="row-upload" style="margin-left:180px;margin-top:15px">
								<input id="file_upload" name="file_upload" type="file" multiple="true">
							</div>
							
							<div id="show-img">
								
								<!--  
								<div class="img-row">
									<input type="hidden" name="picture[]" value="file_a.jpg">
									<img width="100" height="100" src="<?php echo FILES_URL."/photos/images200x200/1353578797_Penguins.jpg" ?>"/>
									<span class='img-del' id='flie_a.jpg'>xóa<span>
								</div>
								
								-->
								<?php 
								
								if($this->the_action=='edit')
								{
									$mod=new Zendvn_Models_Pictures();
									$items=$mod->listItem(array('p_id'=>$this->Item['id']),array('task'=>'public-list'));
									foreach ($items as $item)
									{
										$pic=$item['img'];
										$id=$item['id'];
								?>
								<div class="img-row">
									<input type="hidden" name="picture[]" value="<?php echo $pic ?>">
									<img width="100" height="100" src="<?php echo FILES_URL."/photos/images200x200/$pic" ?>"/>
									<span class="img-del" id="<?php echo $id ?>" title="<?php echo $pic ?>">xóa</span>
								</div>
								<?php }} ?>
								
							</div>
							
							<script type="text/javascript">
							 		$(".img-del").live('click',function(){
										 var id=$(this).attr('id');
										 var img=$(this).attr('title');
										 var datas='img='+img+'&id='+id;
										 $.ajax
										 ({
											type:'post',
											url :'<?php echo $this->baseUrl("/photos/admin-photo-item/ajax") ?>',
											data:datas,
											success:function()
											{
													
											}
										 });

										 $(this).parents("div:first").remove();	
											
												 
								 	});								 							 
							</script>
							
						 </div>					 
											
                             <!-- END: ELEMENT BOX -->	
                             <div class="clr"></div>
                            </div>
                            <div class="b">
                                <div class="b">
                                    <div class="b"></div>
                                </div>
                            </div>
                        </div>
                        <!-- END: 	CONTENT -->                                 
</form>

<script type="text/javascript">
		<?php $timestamp = time();?>
		$(function() {
			$('#file_upload').uploadify({
				'formData'     : {
					'timestamp' : '<?php echo $timestamp;?>',
					'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
				},
				'fileSizeLimit' : '1000KB',
				'fileTypeDesc' : 'Image Files',
				'fileTypeExts' : '*.gif; *.jpg; *.png ; *.jpeg',
				'swf'      : '<?php echo PUBLIC_URL.'/uploadify/uploadify.swf' ?>',
				'uploader' : '<?php echo PUBLIC_URL.'/uploadify/uploadify.php' ?>',
				'onUploadSuccess' : function(file, data, response)
				{
					$("#show-img").prepend(data);
				}
			});
		});
</script>
